<template>
  <div>
    <!--顶部滑动块区域-->
    <div id="slider" class="mui-slider">
      <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
        <div class="mui-scroll">
          <a :class="['mui-control-item', items === '全部' ? 'mui-active' : '']" v-for="(items, i) in list" :key="i+1">
            {{items}}
          </a>
        </div>
      </div>

    </div>

    <!--图片列表区域-->
    <ul class="photo-list">
      <router-link tag="li" :to="'/home/photosinfo/'+item.id" v-for="item in imglist" :key="item.id">
        <img v-lazy="item.path">
        <div class="info">
          <h1 class="info-title">{{item.title}}</h1>
          <div class="info-body">{{item.zaiyao}}</div>
        </div>
      </router-link>
    </ul>
    <h2>图片组件</h2>
  </div>
</template>

<script>
// 导入mui的js文件
import mui from '@/lib/js/mui.min'

export default {
  name: 'photoslist',
  data () {
    return {
      list: ['家具生活', '手机壁纸', '电脑壁纸', '明星', '科技', '热图'],
      imglist: [
        { id: 1, path: 'https://scpic1.chinaz.net/Files/pic/pic9/202101/apic30151_s.jpg', title: '王者气息1', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' },
        { id: 2, path: 'https://scpic3.chinaz.net/Files/pic/pic9/202101/apic30145_s.jpg', title: '王者气息2', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' },
        { id: 3, path: 'https://scpic.chinaz.net/Files/pic/pic9/202101/apic30547_s.jpg', title: '王者气息3', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' },
        { id: 4, path: 'https://scpic.chinaz.net/Files/pic/pic9/202101/apic30523_s.jpg', title: '王者气息4', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' },
        { id: 5, path: 'https://scpic.chinaz.net/Files/pic/pic9/202101/apic30631_s.jpg', title: '王者气息5', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' },
        { id: 6, path: 'https://scpic1.chinaz.net/Files/pic/pic9/202101/apic30160_s.jpg', title: '王者气息6', zaiyao: '不要简朴不要素雅洋气卧室我做主，高低床樱根来式靓丽卧室装扮,现代油画壁画帆布画卧室餐厅仔象映画，现代中式卧室装修囤欣堂，温罄浪混，而且很时尚的卧室设计，欧式卧室飘\n' }
      ]
    }
  },
  created () {
    this.getAllCatalog()
  },
  methods: {
    getAllCatalog () {
      this.list.unshift('全部')
    }
  },
  mounted () {
    // 初始化滑动控件
    mui('.mui-scroll-wrapper').scroll({
      deceleration: 0.0005
    })
  }
}
</script>

<style lang="scss" scoped>
  *{
    touch-action: pan-y;
  }

  .photo-list{
    list-style: none;
    margin: 0;
    padding: 10px;
    li{
      background-color: #ccc;
      text-align: center;
      margin-bottom: 10px;//底部10px
      box-shadow: 0 0 9px #999;//设置边框阴影
      position: relative;//设置相对定位
      img{
        width: 100%;//全屏显示
        vertical-align: middle; //消除图片底部的灰色
      }

      img[lazy=loading] {//懒加载
        width: 40px;
        height: 300px;
        margin: auto;
      }
      .info{
        color: white;
        text-align: left;
        position: absolute;//设置绝对定位
        bottom: 0;//将信息挤到图片上面
        background-color: rgb(0,0,0,0.4);//设置背景透明
        max-height: 84px;
        .info-title{
          font-size: 14px;
        }
        .info-body{
          font-size: 13px;
        }
      }
    }
  }
</style>
